﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Text;

namespace Web_HengliSeed.en_us
{
    public partial class Product : PageBase
    {
        public string Title = string.Empty;
        public string Date = string.Empty;
        public string Content = string.Empty;
        public string Image = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetData();
            }
        }

        public string GetProClass()
        {
            using (OleDbDataReader read = BLL.ProductInfo.GetClassMesAll(language))
            {
                StringBuilder sbHtml = new StringBuilder();
                sbHtml.Append("<ul>");
                while (read.Read())
                {
                    sbHtml.Append(string.Format("<li><a href='Products.aspx?c={0}'>{1}</a></li>", read["T_ProClassID"], read["T_ProClassName"]));
                }
                sbHtml.Append("</ul>");

                return sbHtml.ToString();
            }
        }

        public void GetData()
        {
            using (OleDbDataReader red = BLL.ProductInfo.GetProInfo(Request["s"]))
            {
                while (red.Read())
                {
                    Title = red["T_ProductName"].ToString();
                    Content = Server.HtmlDecode(red["T_ProductNote"].ToString());
                    //Date = String.IsNullOrEmpty(red["T_DateTime"].ToString()) ? DateTime.Now.ToShortDateString() : DateTime.Parse(red["T_DateTime"].ToString()).ToShortDateString();
                    Image = red["T_ProductImage"].ToString();
                    if (!String.IsNullOrEmpty(Image))
                    {
                        Image = string.Format("<img src='{0}' />", "../upload/image/" + Image);
                    }
                }
            }
        }
    }
}